package com.sf.algo.solve.domain;

import com.sf.algo.shortpath.Coord;

public class Location {

	private final int x;

	private final int y;
	
	public Location(Coord coord) {
		this.x = coord.getX();
		this.y = coord.getY();
	}
	
	public Location(int x, int y) {
		super();
		this.x = x;
		this.y = y;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public int getDistance(Location location) {
		return Math.abs(x - location.x) + Math.abs(y - location.y);
	}

	public static void main(String[] args) {
		Location l1 = new Location(0, 1);
		Location l2 = new Location(2, 3);
		System.out.println(l1.getDistance(l2));
	}

	@Override
	public String toString() {
		return String.format("(%s,%s)", x, y);
	}

}
